/**
 * fileName:  NutritionType.java
 * author:  Lei
 * Company:  Cloudland Studio
 * Createdate:  2014-5-27 下午10:38:34
 *
 * All rights Reserved, Designed By cloudland Copyright(C) 2010-2011
 *   
 * Modification  History:
 *     Date           Author        Version        
 * -------------------------------------------
 * 2014-5-27          Lei            1.0        
 *
 * Why & What is modified:
 * 1.0: 文件创建
 */
package org.cloudland.commercial.masterdata.bean;

 /**
 * <pre> 
 * 营养类型
 * </pre>
 * @ClassName  NutritionType
 * @author  Lei
 * @version  %I%, %G%
 * @see  
 * @since   JDK1.6
 *
 */
public enum NutritionType implements Type {
	
	/**
	 * NUTRIENT 营养素
	 */
	NUTRIENT("1", "营养素"),
	
	/**
	 * VITAMI 维生素
	 */
	VITAMI("2", "维生素"),
	
	/**
	 * MINERAL 矿物质
	 */
	MINERAL("3", "矿物质");
	
	/**
	 * code 类型编码
	 */
	private String code;
	
	/**
	 * desc 类型描述
	 */
	private String desc;
	
	NutritionType(String val, String desc){
		this.code = val;
		this.desc = desc;
	}
	
	/**
	 * 获取类型描述
	 * @return desc
	 */
	public String desc() {
		return desc;
	}
	
	/**
	 * 获取类型编码
	 * @return
	 */
	public String code() {
		return this.code;
	}
	
	/**
	 * @return
	 */
	@Override
	public String toString() {
		StringBuffer buff = new StringBuffer();
		buff.append(code()).append(":").append(desc());
		return buff.toString();
	}
	
	/**
	 * 
	 * 按营养类型编号获取领域中营养类型的枚举
	 *
	 * @param code 营养类型编号
	 * @return 营养类型的枚举对象
	 */
	public static NutritionType getTypeByCode(String code)
	{
		NutritionType result = null;
		if (code==null || code.length()<1)
		{
			return result;
		}
		for (NutritionType temp : NutritionType.values())
		{
			if (code.equals(temp.code()))
			{
				result = temp;
				break;
			}
		}
		return result;
	}
	
}
